package cn.xiaopengstack.domain.trade.rule.trade;

import cn.xiaopengstack.domain.activity.repository.IActivityRepository;
import cn.xiaopengstack.domain.trade.rule.factory.TradeRuleFilterFactory;
import cn.xiaopengstack.domain.trade.model.entity.TradeRuleCommandEntity;
import cn.xiaopengstack.domain.trade.model.entity.TradeRuleResponseEntity;
import cn.xiaopengstack.domain.trade.repository.ITradeRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author jiangyangang
 */
@Service
@Slf4j
public class EndNodeLockFilter extends AbstractTradeLogicLink<TradeRuleCommandEntity, TradeRuleFilterFactory.DynamicContext, TradeRuleResponseEntity>{

    public EndNodeLockFilter(ITradeRepository tradeRepository, IActivityRepository activityRepository) {
        super(tradeRepository, activityRepository);
    }

    @Override
    public TradeRuleResponseEntity apply(TradeRuleCommandEntity request, TradeRuleFilterFactory.DynamicContext dynamic) throws Exception {
        return TradeRuleResponseEntity.builder()
                .userTakeOverActivityCount(dynamic.getUserTakeOverActivityCount())
                .build();
    }
}
